<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Custom_View_Helper_SortLink extends Zend_View_Helper_Abstract
{

	public function sortLink($label, $filed = 'id')
	{
		$url_params = array();
		$orderDir = $this->view->orderDir;
		$request = Zend_Controller_Front::getInstance()->getRequest();
		if($request->getParam('page')) $url_params['page'] = $request->getParam('page');
		$url_params['sort'] = $filed;
		$url_params['dir']  = (isset($orderDir[$filed]))?$orderDir[$filed]:'';


		if(isset($orderDir) && key($orderDir) == $filed)
		{
			$img_path = '/images/s_'.strtolower($orderDir[$filed]).'.png';
			$link = '<a href="'. $this->view->url($url_params).'">'.$label.'</a>&nbsp;<img src="'. $this->view->baseUrl($img_path).'"/>';
		}
		else
			$link = '<a href="'. $this->view->url($url_params).'">'.$label.'</a>';

		return $link;
	}
}
?>
